package com.adee.design.action.promise;

import com.adee.util.Utils;

public class Test {
    public static void main(String[] args) {
        MyTask<String, String> task = new MyTask<String, String>(s -> {
            //Utils.sleep(15);
            return "hello, " + s;
        });
        IPromise<String> promise = task.runAsync("Jack");
        Utils.sleep(15);
        MyPromise.Result<String> result = promise.get();
        Throwable t = result.getT();
        if(t != null) {
            t.printStackTrace();
        } else {
            System.out.println(result.getData());
        }
    }
}
